package com.ifgi.sitcom.campusmapperNDrawer.handlers;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.view.Gravity;
import android.view.LayoutInflater;
//import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.actionbarsherlock.view.MenuItem;
import com.ifgi.sitcom.campusmapperNDrawer.R;
import com.ifgi.sitcom.campusmapperNDrawer.views.ImageViewBase;




/*
 * defined form of classes to control ui behaviour when certain 
 * data type (such as corridor or room) is selected
 */
public abstract class UIActionHandler extends Activity{
	
	
	public abstract void handleMenuAction(MenuItem item);
	
	public abstract int getMenu();
	
//	public abstract boolean onPrepareOptionsMenu(Menu menu);
	
	public abstract void draw(Canvas canvas, float scaleFactor);
	
	public abstract boolean handleTouchEvent(MotionEvent ev, float scaleFactor, int xPos, int yPos);
	
	public abstract void init(ImageViewBase imageViewBase);
	
	public void showToastPoints(Context context, String string)
	{
		LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
		
		View layout = inflater.inflate(R.layout.toast,
		                    null );

		TextView text = (TextView) layout.findViewById(R.id.text_toast);
		text.setText(string+" points");
		if(text.getText().subSequence(0, 1).equals("+"))
		{
			text.setTextColor(Color.GREEN);	
		}
		else text.setTextColor(Color.RED);
		
		Toast toast = new Toast(context);
		//toast.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT, 0, 0);
		toast.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0);
		toast.setDuration(Toast.LENGTH_LONG);
		toast.setView(layout);
		toast.show();
	}
	
}
